package com.danco.training.zaneuskaya.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * @author Zaneuskaya Aliaksandra
 *
 */
@Entity
@Table(name = "education")
public class Education implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -2998842693686070674L;

	@Id
	@GeneratedValue
	@Column(name = "education_id")
	private Integer educationId;

	@Column(name = "education_start")
	@Temporal(value = TemporalType.DATE)
	private Date educationStart;

	@Column(name = "education_end")
	@Temporal(value = TemporalType.DATE)
	private Date educationEnd;

	@Column(name = "education_type")
	@Enumerated(EnumType.STRING)
	private EducationType educationType;

	@Column(name = "institution_title")
	private String institutionTitle;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "country_fk", referencedColumnName = "country_id")
	private Country educationCountry;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "city_fk", referencedColumnName = "city_id")
	private City educationCity;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "user_fk", referencedColumnName = "user_id")
	private User userEducation;

	public Integer getEducationId() {
		return educationId;
	}

	public void setEducationId(Integer educationId) {
		this.educationId = educationId;
	}

	public Date getEducationStart() {
		return educationStart;
	}

	public void setEducationStart(Date educationStart) {
		this.educationStart = educationStart;
	}

	public Date getEducationEnd() {
		return educationEnd;
	}

	public void setEducationEnd(Date educationEnd) {
		this.educationEnd = educationEnd;
	}

	public EducationType getEducationType() {
		return educationType;
	}

	public void setEducationType(EducationType educationType) {
		this.educationType = educationType;
	}

	public String getInstitutionTitle() {
		return institutionTitle;
	}

	public void setInstitutionTitle(String institutionTitle) {
		this.institutionTitle = institutionTitle;
	}

	public Country getEducationCountry() {
		return educationCountry;
	}

	public void setEducationCountry(Country educationCountry) {
		this.educationCountry = educationCountry;
	}

	public City getEducationCity() {
		return educationCity;
	}

	public void setEducationCity(City educationCity) {
		this.educationCity = educationCity;
	}

	public User getUserEducation() {
		return userEducation;
	}

	public void setUserEducation(User userEducation) {
		this.userEducation = userEducation;
	}

	@Override
	public int hashCode() {
		return getEducationId();
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof Education) {
			Education other = (Education) obj;
			return other.getEducationId() == educationId;
		}
		return false;
	}

}
